#include <stdio.h>
#include <stdlib.h>

float getSquareByNewtonsMethod(float num, float init);

int main(int argc, char* argv[])
{
    if(argc != 2)
    {
        printf("Usage: %s [number]\n",argv[0]);
        return -1;
    }

    float num = atof(argv[1]);
    printf("Input=%f\n",num);
    printf("square output is %f\n",getSquareByNewtonsMethod(num,1));
}



float getSquareByNewtonsMethod(float num, float init)
{
   init =  (init + (num/init)) /2.0;
   if( abs(num - (init*init)) < 0.00000001 )    
        return init;
   getSquareByNewtonsMethod(num,init);
}
